﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Configuration;
using VK.Comm;
using VK.Casemeet.Employees;
using VK.Casemeet.Merchants;

namespace VK.Casemeet.Web.ShopAdmin
{
    public partial class EditPass : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            (this.Master as Site).SiteMapPathControl.MapPathList = new List<MapPath>(){
                new MapPath{ Text="桌面",Url="Home.aspx"},
                new MapPath{ Text="修改密码",Url="#"}
            };
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            string strMessage = "";
            if (string.IsNullOrEmpty(txtOldPass.Text))
            {
                strMessage += "原密码不能为空!\\n";
            }
            if (string.IsNullOrEmpty(txtNewPass.Text))
            {
                strMessage += "新密码不能为空!\\n";
            }
            if (txtNewPass.Text != txtNewPassCheck.Text)
            {
                strMessage += "验证密码与新密码要输入相同!\\n";
            }
            if (strMessage.Length != 0)
            {
                Message.Msg(this.Page, strMessage, MessageType.Failure);
                return;
            }
            if (AdminBLL.SetAdminPassword(
                AdminBLL.GetSessionAdmin().AdminID,
                DES.Encrypt(txtOldPass.Text, CS.ShopAdminPassKey),
                DES.Encrypt(txtNewPass.Text, CS.ShopAdminPassKey)) == 1)
            {
                Message.Msg(this.Page, CS.MsgEditSuccess, MessageType.Success);
            }
            else
            {
                Message.Msg(this.Page, CS.MsgEditFailure, MessageType.Failure);
            }
        }
    }
}